﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using PICOC.Silverlight.View.ReportBugServiceReference;

namespace PICOC.Silverlight.View.Modals
{
    public partial class ReportBugModal : UserControl
    {
        public event EventHandler OnClose;

        public ReportBugModal()
        {
            InitializeComponent();
        }

        private void btSend_Click(object sender, RoutedEventArgs e)
        {
            btSend.IsEnabled = false;
            TextBlock_MouseLeftButtonDown(sender, null);

            ReportBugServiceClient client = new ReportBugServiceClient();
            client.SendReportCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_SendReportCompleted);
            tbMessage.SelectAll();
            client.SendReportAsync(tbName.Text, tbMessage.Selection.Text);
        }

        void client_SendReportCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            
        }

        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            tbName.Text = String.Empty;
            tbMessage.SelectAll();
            tbMessage.Selection.Text = String.Empty;

            OnClose.Invoke(sender, e);
        }
    }
}
